window.alert("当前url为:"+location.href)
let i = 0;
if (confirm("3秒之后跳转到百度官网"))
    setTimeout(function () {
        location.href="https://www.baidu.com/"
    }, 3000);
else
    setInterval(function () {
        if (i++ < 3)
            window.alert("定时器执行了" + i + "次");
        else return;
    }, 1000);